/*
 * Copyright 2017-8-30 13:56:25 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.admin.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.admin.core.DeptManager;
import com.lap.scp.admin.dal.DeptDAO;
import com.lap.scp.admin.domain.DeptDO;
import com.lap.scp.admin.query.DeptQueryDO;

/**
 * <pre>
 * 部门业务操作对象，提供事物控制层
 * </pre>
 * 
 * @author 系统自动生成 Exp
 * @Date 2017-8-30 13:56:25
 * @since 1.0
 */
@Service("deptManager")
public class DefaultDeptManager implements DeptManager {

	@Resource
	private DeptDAO deptDAO;

	@Override
	public int deleteById(int deptId) throws ManagerException {
		return deptDAO.deleteById(deptId);
	}

	@Override
	public void insertDept(DeptDO deptDO) throws ManagerException {
		deptDAO.insertDept(deptDO);
	}

	@Override
	public DeptDO queryById(int deptId) throws ManagerException {
		return deptDAO.queryById(deptId);
	}

	@Override
	public List<DeptDO> queryPage(Page page, DeptQueryDO queryDO) throws ManagerException {
		int count = deptDAO.countPage(queryDO);
		if (count <= 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return deptDAO.queryPage(page, queryDO);
		}
	}

	@Override
	public int updateDept(DeptDO deptDO) throws ManagerException {
		return deptDAO.updateDept(deptDO);
	}

}
